import time

from src.main.page.login_page import Login_page



def test_run1():
    login = Login_page()
    main_page = login.login()
    contact_page = main_page.goto_contact()
    # 选中部门
    contact_page.point_to_department_by_department_name('冼喆之家123')
    #往部门里添加成员
    # 进入添加成员页面
    add_member_page = contact_page.goto_add_member_page()
    name = add_member_page.add_member()[0]

    #删除新增的成员
    member_list = contact_page.get_member_list()

    for index, i in enumerate(member_list):

        if i.text == name:
            contact_page.delete_member_single(index)
            break
    contact_page.add_a_lot_member_when_exist()

    time.sleep(8000)



def test_run():
    login = Login_page()
    main_page = login.login()
    #进入通讯录页面
    contact_page = main_page.goto_contact()
    #进入添加成员页面
    add_member_page = contact_page.goto_add_member_page()
    #添加新成员
    newer_name = add_member_page.add_member()[0]
    #获取成员列表，对新添加的成员的删除
    member_list = contact_page.get_member_list()

    for index,i in enumerate(member_list):

        if i.text ==newer_name:
            contact_page.delete_member_single(index)
            break
    #点击添加部门
    success_text = contact_page.click_deparkment_btn_add_department()[1]
    assert success_text=='新建部门成功'
    #往新增部门里添加成员
    contact_page.add_member_after_add_department()
    name = add_member_page.add_member()[0]
    #将新增的成员进行删除
    member_list = contact_page.get_member_list()

    for index, i in enumerate(member_list):

        if i.text == name:
            contact_page.delete_member_single(index)
            break

    #删除新增的部门
    contact_page.delete_department()
    #前往添加成员的页面，进行空值校正
    contact_page.goto_add_member_page()

    add_member_page.check_input_is_empty()
    time.sleep(80000)




